package cn.iocoder.yudao.module.trade.order.vo;

import cn.iocoder.yudao.module.api.dine.enums.DineStatusEnum;
import cn.iocoder.yudao.module.api.trade.delivery.enums.DeliveryTypeEnum;
import cn.iocoder.yudao.module.api.trade.order.enums.TradeOrderRefundStatusEnum;
import cn.iocoder.yudao.module.api.trade.order.enums.TradeOrderStatusCodeEnum;
import cn.iocoder.yudao.module.api.trade.order.enums.TradeOrderStatusEnum;

import java.util.Objects;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  订单状态名称获取器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/01/03
 */
public interface TradeOrderStatusNameGetter {

    default String assignStatusName(Integer deliveryType, Integer status, Boolean commentStatus, Integer refundStatus, Integer dineStatus) {
        if (Objects.equals(status, TradeOrderStatusEnum.UNPAID.getStatus())) {
            return TradeOrderStatusCodeEnum.PAYMENT.getName();
        }
        if (!Objects.equals(TradeOrderRefundStatusEnum.NONE.getStatus(), refundStatus)) {
            return TradeOrderStatusCodeEnum.REFUND.getName();
        }
        if (Objects.equals(status, TradeOrderStatusEnum.PAID.getStatus())) {
            if (Objects.equals(DeliveryTypeEnum.EXPRESS.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.DELIVERY.getName();
            }
            if (Objects.equals(DeliveryTypeEnum.TAKE_OUT.getType(), deliveryType)) {
                return DineStatusEnum.getByValue(dineStatus).getName();
            }
            if (Objects.equals(DeliveryTypeEnum.VERIFY.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.CLERK.getName();
            }
            if (Objects.equals(DeliveryTypeEnum.ONSITE.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.ONSITE.getName();
            }
            return TradeOrderStatusCodeEnum.PAID.getName();
        }
        if (Objects.equals(status, TradeOrderStatusEnum.DOING.getStatus())) {
            if (Objects.equals(DeliveryTypeEnum.EXPRESS.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.RECEIVE.getName();
            }
            if (Objects.equals(DeliveryTypeEnum.TAKE_OUT.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.ARRIVING.getName();
            }
            if (Objects.equals(DeliveryTypeEnum.PICK_UP.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.CLERK.getName();
            }
            if (Objects.equals(DeliveryTypeEnum.VERIFY.getType(), deliveryType)) {
                return TradeOrderStatusCodeEnum.CLERK.getName();
            }
            return TradeOrderStatusCodeEnum.DOING.getName();
        }
        if (Objects.equals(status, TradeOrderStatusEnum.COMPLETED.getStatus())) {
            if (!Boolean.TRUE.equals(commentStatus)) {
                return TradeOrderStatusCodeEnum.COMMENT.getName();
            }
            return TradeOrderStatusCodeEnum.COMPLETE.getName();
        }
        if (Objects.equals(status, TradeOrderStatusEnum.CLOSED.getStatus())) {
            return TradeOrderStatusCodeEnum.CLOSED.getName();
        }
        return "--";
    }

}
